package com.project.service.impl;

import com.project.bean.ClassBean;
import com.project.dao.IClassDao;
import com.project.dao.IStudentDao;
import com.project.dao.impl.ClassDaoImpl;
import com.project.dao.impl.StudentDaoImpl;
import com.project.service.IClassService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClassServiceImpl implements IClassService {
    @Autowired
    private IClassDao dao ;
    @Autowired
    private IStudentDao dao1 ;
    @Override
    public List<ClassBean> findAll() {
        return dao.findAll();
    }

    @Override
    public boolean del(Integer id) {
        if (dao1.countByClass(id)==0){
            dao.del(id);
            return true;
        }else {
            return false;
        }
    }

    @Override
    public void add(ClassBean classBean) {
       dao.add(classBean);
    }
}
